package com.define.ssh.service.impl;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.define.ssh.dao.UserInfoDao;
import com.define.ssh.model.UserInfo;
import com.define.ssh.service.UserInfoService;
import com.define.ssh.util.Pager;

@Service("userInfoServiceImpl")
public class UserInfoServiceImpl extends BaseServiceImpl<UserInfo, Long>
		implements UserInfoService {

	@Resource(name = "userInfoDaoImpl")
	private UserInfoDao userInfoDao;

	@Resource(name = "userInfoDaoImpl")
	public void setBaseDao(UserInfoDao userInfoDao) {
		super.setBaseDao(userInfoDao);
	}

	@Override
	public UserInfo getUserInfoByLogin(String login) {
		return userInfoDao.getUserInfoByLogin(login);
	}

	@Override
	@Transactional(readOnly = true)
	public boolean isExistByLogin(String login) {
		return userInfoDao.isExistByLogin(login);
	}

	/**
	 * 根据角色id删除 对应角色的用户
	 * 
	 * @param role_id
	 *            角色id
	 */
	@Override
	public void delUserInfoByRole(Long role_id) {
		userInfoDao.delUserInfoByRole(role_id);
	}

	/**
	 * 账号管理列表
	 */
	@Override
	public Pager findPagerByAccount(Pager pager) {
		return userInfoDao.findPagerByAccount(pager);
	}

	@Override
	public Pager findPagerByPowers(Pager pager, List<Integer> powers_list) {
		return userInfoDao.findPagerByPowers(pager, powers_list);
	}
}
